﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Areas/Admin/Views/Shared/AdminSite.Master" Inherits="System.Web.Mvc.ViewPage<Sys.WebRes.Publish.Areas.Admin.Models.AttachmentModel>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	附件管理
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="HeadContent" runat="server">
	<script type="text/javascript" language="javascript">
	    $(function () {
	        $('#mainGrid').datagrid({
	            title: '附件一览',
	            url: '<%=Url.Action("List")%>',
	            iconCls: 'icon-edit',
	            singleSelect: false,
	            method: 'get',
                cache:false,
	            width: 850,
	            height: 'auto',
	            fitColumns: false,
	            idField: 'ID',
	            pagination: true,
	            rownumbers: false,
	            columns: [[
                        { field: 'ID', title: '操作', width: 70, align: 'center', formatter: operatorFormatter },
				        { field: 'Title', title: '标题', width: 150, align: 'left' },
				        { field: 'Summary', title: '概要', width: 200, align: 'left' },
				        { field: 'FilePath', title: '相对路径', width: 150, align: 'left' },
				        { field: 'PicSize', title: '图片大小', width: 60, align: 'center' },
				        { field: 'CustomType', title: '自定义区分', width: 80, align: 'center' },
                        { field: 'CDateString', title: '创建日', width: 100, align: 'center' }
			        ]],
                toolbar: [
                    {
                        text: '新建',
                        iconCls: 'icon-add',
                        handler: function () {
                            openEditWin(null, -1);
                        }
                    }, '-', {
                        text: '删除选中',
                        iconCls: 'icon-remove',
                        handler: function () {
                             
                        }
                    }, '-', {
                        text: '删除全部',
                        iconCls: 'icon-remove',
                        handler: function () {

                        }
                    }
                ]
	        }); //grid完毕

	        //资源类型改变时
	        $('#resTypeSel').combobox({ onChange: function (nw, od) {
	            $('#mainGrid').datagrid("reload", {id:nw, t:(new Date()).getTime()});
	        } 
	        });
	    });  //初始化函数完毕

	    //
	    //操作列格式化函数
        //
	    function operatorFormatter(value) {
	        return value +
	               '&nbsp;<input onclick="openEditWin(this,' + value + ');" type="button" class="icon-edit" style="width:20px;" val="编辑"/>' +
                   '<input onclick="deleteRow(' + value + ');" type="button" class="icon-cut" style="width:20px;" val="删除"/>' +
                   ((value < 0) ? '*' : '　');
	    }
	    //
	    //初始化函数
        //
	    $().ready(function () {
	        $(".restype").click(function () {
	            if (this.checked) {
	                $("#ResTypeID").val(this.value);
	                $('#mainGrid').datagrid("reload", { id: this.value, ctype: $("#customType").val(), t: (new Date()).getTime() });
	            }
	        });

	        $("#customType").keyup(function (e) {
	            if (e.keyCode == 13) {
	                $('#mainGrid').datagrid("reload", { id: $("#ResTypeID").val(), ctype: this.value, t: (new Date()).getTime() });
	            }
	        });
	    });

	    function openEditWin(link, id) {
	        if (id > 0) {//编辑
	            openWindow("编辑附件", '<%=Url.Action("Edit") %>/' + id, null, null, 500, 500);
	        } else {//新建
	            openWindow("添加附件", '<%=Url.Action("Edit") %>', null, null, 500, 500);
	        }
        }
    </script>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="BodyContent" runat="server">
    <div class="demo-info">
		<div class="demo-tip icon-tip"></div>
		<table style="width:100%;">
            <tr><td style="width:30%;">
                <input type="hidden" id="ResTypeID" value=""/>
                <input type="radio" id="NoneType" value="" name="ExtType" class="restype" checked />
                <label for="NoneType">未指定</label>
                <input type="radio" id="FileType" value="<%=ResType.File.ID %>" name="ExtType" class="restype"/>
                <label for="FileType"><%=ResType.File.Name%></label>
                <input type="radio" id="PictureType" value="<%=ResType.Picture.ID %>" name="ExtType" class="restype" />
                <label for="PictureType"><%=ResType.Picture.Name %></label>
                <input type="radio" id="MediaType" value="<%=ResType.Media.ID %>" name="ExtType" class="restype" />
                <label for="MediaType"><%=ResType.Media.Name%></label>
            </td><td>
                <label for="customType">自定义区分</label>
                <input type="text" name="customType" id="customType" />
            </td></tr>
        </table>
	</div>
    <div class="operator"></div>
    <table id="mainGrid"></table>
    <div class="demo-info">
		<div class="demo-tip icon-tip"></div>
		<div>
            <ul>
                <li>此画面管理网站所有附件文件，您也可以按照资源类型进行查看。</li>
            </ul>
        </div>
	</div>
</asp:Content>
